<template>
  <view class="g-content">
    <uni-card
      class="card-course"
      :is-shadow="true"
      v-for="item in list"
      :title="item['课程名']"
      :extra="'申请号:'+item['申请号']"
      :id="item['申请号']"
    > 
      <view><span>申请时间：</span>{{ item['上课时间'] }}</view>
      <view><span>申请地点：</span>{{ item['实验室地点'] }}</view>
      <view><span>申请批复：</span>{{ item['申请批复'] }}</view>
      <view><span>申请状态：</span>{{ toState(item['申请状态']) }}</view>
    </uni-card>
    <div style="height: 120rpx;"></div>
    <hans-tabber :list="tab" class="g-tabbar" style="position:fixed;bottom:0;width:100%;left:0;right:0;" :current="1"></hans-tabber>
  </view>
</template>

<script>
  import Teacher from '../../../api/Teacher.js';
  export default {
    data(){
      return{
        uid: this.$store.state.token.id,
        list: [],
        tab: [
          {
            "text":"学期课程",
            "pagePath":"curriculum",
            "iconPath":"../../../static/icon/task.png",
            "selectedIconPath":"../../../static/icon/task.png"
          },
          {
            "text":"申请记录",
            "pagePath":"apply",
            "iconPath":"../../../static/icon/task.png",
            "selectedIconPath":"../../../static/icon/task.png"
          }
        ]
      }
    },
    onInit() {
      this.uid = this.$store.state.token.id;
    },
    onLoad() {
      this._initList();
    },
    methods:{
      async _initList(){
        const rm = (await Teacher.getMyApply(this.uid));
        this.Test.log('老师-申请信息',rm);
        if(rm[1]['statusCode'] == '200'){
          if(rm[1].data == [] || rm[1].data == ''){
            this.Toast.show('无申请');
            this.list = [];
            return;
          }
          this.list = rm[1].data;
          //this.Toast.show('数据已加载');
        }
      },
      toState(state){
        switch(state){
          case 1:
            return '未批复';
            break;
          case 2:
            return '被拒绝';
            break;
          case 3:
            return '已同意';
            break;
          default:
            break;
        }
        return '';
      }
    }
  }
</script>

<style>
</style>
